<?php

namespace app\api\controller\cps;

use app\common\controller\Api;



/**
 * 拼多多联盟接口
 */
class Pdd extends Api
{
    protected $noNeedLogin = ['orderlist','unliquidated'];
    protected $noNeedRight = ['*'];


    //多多进宝商品查询
    public function goodslist()
    {
        try {
            $page = input('page',1);
            $keyword = input('keyword','');
            $cat_id = input('cat_id','');
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->goodsList($page,$keyword,$cat_id);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //多多进宝商品详情
    public function goodsdetail()
    {
        try {
            $goods_sign = input('goods_sign','');
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->goodsDetail($goods_sign);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //商品推荐
    public function recommendgoods()
    {
        try {
            $activity_tags = input('activity_tags',0);
            $limit = input('limit',10);
            $offset = input('offset',0);
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->recommendGoods($activity_tags,$limit,$offset);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //生成营销工具推广链接
    public function beianurl()
    {
        try {
            $goods_sign = input('goods_sign','');
            $p_id = input('p_id','41195366_292109156');
            $channel_type = input('channel_type',10);
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->beianurl($goods_sign,$p_id,$channel_type);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //多多进宝推广链接生成
    public function url()
    {
        try {
            $goods_sign_list = input('goods_sign_list','');
            $p_id = input('p_id','41195366_292109156');
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->url($goods_sign_list,$p_id,$this->auth->id);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //查询推广订单
    public function orderlist()
    {
        try {
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->orderlist();
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    public function unliquidated()
    {
        try {
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->unliquidated();
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //创建多多进宝推广位
    public function promotionbit()
    {
        try {
            $number = input('number',10);
            $media_id = input('media_id','');
            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->promotionbit($number,$media_id);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //多多进宝推广位列表
    public function promotionbitList()
    {
        try {
            $page= input('page',1);

            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->promotionbitlist($page);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //批量绑定推广位的媒体id
    public function promotionbitBind()
    {
        try {
            $media_id= input('media_id','');

            $pid_list= input('pid_list','');

            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->promotionbitBind($media_id,$pid_list);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //多多进宝转链接口
    public function uniturl()
    {
        try {
            $pid= input('pid','');

            $source_url= input('source_url','');

            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->uniturl($pid,$source_url);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //多多进宝转链接口
    public function resourceurl()
    {
        try {
            $pid= input('pid','41195366_292109156');

            $resource_type= input('resource_type','');

            $jd_model = new \app\api\model\cps\Pdd();

            $res = $jd_model->resourceurl($resource_type,$pid,$this->auth->id);
        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }
}